import tools from '../../../utils/tools'
import Handle from './Handle'
@tools
export default class Event {
    constructor(oList, courseData, cartData, observer) {
        this.oList = oList
        this.oAddBtns = this.oList.getElementsByClassName('add-btn')
        this.courseData = courseData
        this.cartData = cartData
        this.observer = observer
        this.init()
    }
    init() {
        this.bindEvent()
        this.handle = new Handle(this.courseData, this.cartData, this.oAddBtns, this.observer)
    }
    bindEvent() {
        this.oList.addEventListener('click', this.onAddBtnClick.bind(this))
    }
    onAddBtnClick() {
        const tar = Event.getTarget(ev),
            className = tar.className;
        if (className === 'add-btn') {
            const id = tar.getAttribute('data-id');
            this.observer.ontify(this, id, tar, 1)
        }
    }
}